package com.qf.flash.mvp.presenter;

import com.qf.dblib.dao.impl.UserMgr;
import com.qf.flash.http.HttpManager;
import com.qf.flash.model.AccountInfoBean;
import com.qf.flash.model.AlipayInfoBean;
import com.qf.flash.mvp.contract.BusinessInfoContrat;
import com.qf.flashlib.base.BasePresenter;
import com.qf.flashlib.base.BaseSubscriber;
import com.qf.flashlib.util.RxUtils;

/**
 * Des：
 *
 * @author love
 */
public class BusinessInfoPresenter extends BasePresenter<BusinessInfoContrat.View> implements BusinessInfoContrat.Presenter {
    String uid = UserMgr.getInstance().getLoginUser().getUid();

    @Override
    public void getBusinessEnterInfo(String type) {

        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .GET_MYACCOUNT_INFO(uid, type)
                .compose(RxUtils.handleResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<AccountInfoBean>(mRootView) {
                                   @Override
                                   public void onSuccess(AccountInfoBean accountInfoBean) {
                                       mRootView.setAccountInfo(accountInfoBean);
                                   }
                               }
                )
        );

    }

    @Override
    public void getAlipayInfo() {
        addSubscription(HttpManager.getInstance().getGsonHttpApi()
                .GET_ALIPAY_MSG(uid)
                .compose(RxUtils.handleResult())
                .compose(RxUtils.io_main())
                .subscribeWith(new BaseSubscriber<AlipayInfoBean>(mRootView) {
                                   @Override
                                   public void onSuccess(AlipayInfoBean alipayInfoBean) {

                                       mRootView.setAlipayInfoBean(alipayInfoBean);
                                   }
                               }
                )
        );
    }

}
